import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { FactoryVO, FactoryForm, FactoryQuery } from '@/api/pill/factory/types';

/**
 * 查询生产厂家信息列表
 * @param query
 * @returns {*}
 */

export const listFactory = (query?: FactoryQuery): AxiosPromise<FactoryVO[]> => {
  return request({
    url: '/pill/factory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询生产厂家信息详细
 * @param factoryId
 */
export const getFactory = (factoryId: string | number): AxiosPromise<FactoryVO> => {
  return request({
    url: '/pill/factory/' + factoryId,
    method: 'get'
  });
};

/**
 * 新增生产厂家信息
 * @param data
 */
export const addFactory = (data: FactoryForm) => {
  return request({
    url: '/pill/factory',
    method: 'post',
    data: data
  });
};

/**
 * 修改生产厂家信息
 * @param data
 */
export const updateFactory = (data: FactoryForm) => {
  return request({
    url: '/pill/factory',
    method: 'put',
    data: data
  });
};

/**
 * 删除生产厂家信息
 * @param factoryId
 */
export const delFactory = (factoryId: string | number | Array<string | number>) => {
  return request({
    url: '/pill/factory/' + factoryId,
    method: 'delete'
  });
};
